const { save: savePos, patch: patchPos, remove: removePos } = require('../model/position')

const save = async (req, res, next) => {
  res.set('content-type', 'application/json')

  let data = req.body
  let result = await savePos(data)

  res.render('position', {
    data: JSON.stringify(result)
  })
}

const patch = async (req, res, next) => {
  res.set('content-type', 'application/json')
  let data = req.body
  let result = await patchPos(data)

  res.render('position', {
    data: JSON.stringify(result)
  })
}

const remove = async (req, res, next) => {
  res.set('content-type', 'application/json')
  let data = req.body
  let result = await removePos(data)

  res.render('position', {
    data: JSON.stringify(result)
  })
}

module.exports = {
  save,
  patch,
  remove
}